package problem2331;

//2331.计算布尔二叉树的值
//https://leetcode.cn/problems/evaluate-boolean-binary-tree/

class Solution {
    public boolean evaluateTree(TreeNode root) {
        if(root.val == 0) return false;
        else if(root.val == 1) return true;
        else if(root.val == 2) return evaluateTree(root.left) || evaluateTree(root.right);
        else return evaluateTree(root.left) && evaluateTree(root.right);
    }
}